package com.example.lottery.common.exception;


import com.example.lottery.common.errorcode.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper=true)//通过这个注解使用父类的hashcode  equals，而不是使用Data自己生成的equals  hashcode
public class ServiceException extends  RuntimeException {
    private int code;
    private String message;


    public ServiceException(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public ServiceException(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.message = errorCode.getMessage();
    }

    public ServiceException() {}
}
